package com.bianmaba.examples.service.authorization.resource;

import com.bianmaba.examples.bean.authorization.Resource;
import com.bianmaba.examples.bean.authorization.Role;
import com.bianmaba.examples.repository.authorization.resource.ResourceRepository;
import com.bianmaba.spring.data.jpa.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by cwx183898 on 2017/8/9.
 */
@Service
public class ResourceService extends BaseService<Resource, String> implements IResourceService {
    @Autowired
    private ResourceRepository repository;

    @Override
    public ResourceRepository getRepository() {
        return repository;
    }

    @Override
    public <S extends Resource> S save(S entity) {
        if (entity.getId() == null) {
            entity.setCreator("SYSTEM");
        }
        return super.save(entity);
    }
}
